package springCloud.controller;

import com.luoqiu.entities.Payment;
import com.luoqiu.entities.Result;
import org.springframework.cloud.client.loadbalancer.LoadBalanced;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.client.RestTemplate;

import javax.annotation.Resource;

/**
 * @author 洛秋y
 * @date 2020/11/19 16:22
 */
@RestController
public class OrderController {

    //private static final String url = "http://localhost:8001";
    //在服务提供方是多服务的情况下 此时调用服务采用服务名调用
    //服务名 在web端显示的是中划线，在配置时使用的是下划线， 以web端显示的为准
    private static final String url = "http://consul-payment-provider";

    @Resource
    @LoadBalanced
    private RestTemplate restTemplate;

    @GetMapping(value = "/consul/get/{id}")
    public String get (@PathVariable("id")Long id) {
        return restTemplate.getForObject(url + "/consul/get", String.class);
    }


}
